﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Profile;
using System.Configuration;
using Facade;
using System.Collections;
using IronOne.SalesOne.BusinessObjects;

namespace IronOne.SalesOne.SalesOneWeb.SalesActivity
{
    public partial class AppointmentDetails : System.Web.UI.Page
    {
        string contractId;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                contractId = Request.QueryString["id"].ToString();
                string appointmentType = Page.Request.Params["type"].ToString();

                StructureFacade fac = new StructureFacade();
                SalesAppoinments sapp = new SalesAppoinments();
                Policy policy = new Policy();
                policy = fac.GetPolicy(contractId);

                sapp = fac.GetActivity(contractId, Request.QueryString["socode"], DateTime.Parse(Request.QueryString["date"]));

                lblDate.Text = sapp.ApptDate.ToShortDateString();
                lblType.Text = appointmentType;
                lblContractno.Text = sapp.ContractID;
                //lblClientid.Text = sapp.;
                lblDuedate.Text = policy.DueDate;
                lblPremium.Text = policy.Premium.ToString();
                txtSCRemarks.Text = sapp.SCRemark;

                if (!Page.IsPostBack && Request.UrlReferrer.ToString().Contains("ActivityPlan.aspx"))
                    Session["planQueryString"] = Request.UrlReferrer.Query.ToString();
            }
        }

        protected void btnPolicy_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/ContactManagement/PolicyDetails.aspx?con=" + contractId + "&t=s");
        }

        protected void cancel_Click(object sender, EventArgs e)
        {
            if (Session["planQueryString"] != null)
            {
                Response.Redirect("~/SalesActivity/ActivityPlan.aspx" + Session["planQueryString"].ToString(),false);
                Session.Remove("planQueryString");
            }
        }
    }
}
